using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Diagnostics;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using UIProcessSchemaObjects;

namespace UIProcessActivities
{
    [Designer(typeof(SaveFormDesigner), typeof(IDesigner))]
    public partial class SaveForm : SequenceActivity
	{
		public SaveForm()
		{
			InitializeComponent();
		}

        public static DependencyProperty FormProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Form", typeof(UIProcessSchemaObjects.Form), typeof(SaveForm));

        [Description("The Form to be saved to disk")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public UIProcessSchemaObjects.Form Form
        {
            get
            {
                return ((UIProcessSchemaObjects.Form)(base.GetValue(SaveForm.FormProperty)));
            }
            set
            {
                base.SetValue(SaveForm.FormProperty, value);
            }
        }

        public static DependencyProperty FilePathProperty = System.Workflow.ComponentModel.DependencyProperty.Register("FilePath", typeof(string), typeof(SaveForm));

        [Description("The file path where to store the Form to")]
        [Category("Input")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string FilePath
        {
            get
            {
                return ((string)(base.GetValue(SaveForm.FilePathProperty)));
            }
            set
            {
                base.SetValue(SaveForm.FilePathProperty, value);
            }
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            FormHelper.SaveForm(this.Form, this.FilePath);
            return ActivityExecutionStatus.Closed;
        }
	}
}
